package com.tanhua.mongo.api;

import com.tanhua.api.PeachblossomApi;
import com.tanhua.model.mongo.Voice;
import com.tanhua.mongo.util.IdWorker;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

/**
 * @Author 沈大哥
 * @Date 2022/3/7 17:22
 * @Version 1.0
 **/
@DubboService
public class PeachblossomApiImpl implements PeachblossomApi {
    @Autowired
    private MongoTemplate mongoTemplate;
    @Autowired
    private IdWorker idWorker;
    @Override
    public void save(Voice voice) {
        //设置唯一标识
        voice.setVid(idWorker.getNextId("voice"));
        //保存
        mongoTemplate.save(voice);
    }
}
